package inventory.view;

import javax.swing.JPanel;
import javax.swing.SpringLayout;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JCheckBox;
import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;

public class MaterialManagement extends JPanel
{
	private JTextField addTfName;
	private JTextField addTfSpecification;
	private JTextField addTfUnit;
	private JComboBox editcbMaterialName;
	private JTextField editTfNewName;
	private JComboBox editCbSpecification;
	private JTextField editTfUnit;
	private JComboBox addCbCategory;
	private JButton btnAdd;
	private JComboBox editCbCategory;
	private JButton btnUpdate;
	private JRadioButton rdbtnActive;
	private JRadioButton rdbtnInactive;
	private final ButtonGroup buttonGroup = new ButtonGroup();
	
	public MaterialManagement() 
	{
		SpringLayout springLayout = new SpringLayout();
		setLayout(springLayout);
		
		JLabel lblAddNewMaterial = new JLabel("Add New Material");
		springLayout.putConstraint(SpringLayout.NORTH, lblAddNewMaterial, 10, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST, lblAddNewMaterial, 10, SpringLayout.WEST, this);
		add(lblAddNewMaterial);
		
		JLabel lblName = new JLabel("Material Name");
		springLayout.putConstraint(SpringLayout.NORTH, lblName, 63, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST, lblName, 136, SpringLayout.WEST, this);
		add(lblName);
		
		JLabel lblCategory = new JLabel("Category");
		springLayout.putConstraint(SpringLayout.NORTH, lblCategory, 28, SpringLayout.SOUTH, lblName);
		springLayout.putConstraint(SpringLayout.EAST, lblCategory, 0, SpringLayout.EAST, lblName);
		add(lblCategory);
		
		JLabel lblSpecification = new JLabel("Specification");
		springLayout.putConstraint(SpringLayout.NORTH, lblSpecification, 22, SpringLayout.SOUTH, lblCategory);
		springLayout.putConstraint(SpringLayout.EAST, lblSpecification, 0, SpringLayout.EAST, lblName);
		add(lblSpecification);
		
		JLabel lblUnit = new JLabel("Unit");
		springLayout.putConstraint(SpringLayout.NORTH, lblUnit, 21, SpringLayout.SOUTH, lblSpecification);
		springLayout.putConstraint(SpringLayout.EAST, lblUnit, 0, SpringLayout.EAST, lblName);
		add(lblUnit);
		
		addTfName = new JTextField();
		springLayout.putConstraint(SpringLayout.NORTH, addTfName, 63, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST, addTfName, 6, SpringLayout.EAST, lblName);
		springLayout.putConstraint(SpringLayout.EAST, addTfName, 137, SpringLayout.EAST, lblName);
		add(addTfName);
		addTfName.setColumns(10);
		
		addCbCategory = new JComboBox();
		springLayout.putConstraint(SpringLayout.NORTH, addCbCategory, 19, SpringLayout.SOUTH, addTfName);
		springLayout.putConstraint(SpringLayout.WEST, addCbCategory, 6, SpringLayout.EAST, lblCategory);
		springLayout.putConstraint(SpringLayout.EAST, addCbCategory, 0, SpringLayout.EAST, addTfName);
		add(addCbCategory);
		
		addTfSpecification = new JTextField();
		springLayout.putConstraint(SpringLayout.NORTH, addTfSpecification, 19, SpringLayout.SOUTH, addCbCategory);
		springLayout.putConstraint(SpringLayout.WEST, addTfSpecification, 6, SpringLayout.EAST, lblSpecification);
		springLayout.putConstraint(SpringLayout.EAST, addTfSpecification, 0, SpringLayout.EAST, addTfName);
		add(addTfSpecification);
		addTfSpecification.setColumns(10);
		
		addTfUnit = new JTextField();
		springLayout.putConstraint(SpringLayout.NORTH, addTfUnit, 15, SpringLayout.SOUTH, addTfSpecification);
		springLayout.putConstraint(SpringLayout.WEST, addTfUnit, 6, SpringLayout.EAST, lblUnit);
		springLayout.putConstraint(SpringLayout.EAST, addTfUnit, 0, SpringLayout.EAST, addTfName);
		add(addTfUnit);
		addTfUnit.setColumns(10);
		
		btnAdd = new JButton("Add");
		springLayout.putConstraint(SpringLayout.NORTH, btnAdd, 6, SpringLayout.SOUTH, addTfUnit);
		springLayout.putConstraint(SpringLayout.WEST, btnAdd, 203, SpringLayout.WEST, this);
		add(btnAdd);
		btnAdd.setActionCommand("add");
		
		JLabel lblEditNewMaterial = new JLabel("Edit Material");
		springLayout.putConstraint(SpringLayout.WEST, lblEditNewMaterial, 0, SpringLayout.WEST, lblAddNewMaterial);
		add(lblEditNewMaterial);
		
		JLabel lblName_1 = new JLabel("Material Name");
		springLayout.putConstraint(SpringLayout.NORTH, lblName_1, 102, SpringLayout.SOUTH, lblUnit);
		springLayout.putConstraint(SpringLayout.EAST, lblName_1, 0, SpringLayout.EAST, lblName);
		add(lblName_1);
		
		JLabel lblNewName = new JLabel("New Name");
		springLayout.putConstraint(SpringLayout.SOUTH, lblEditNewMaterial, -53, SpringLayout.NORTH, lblNewName);
		springLayout.putConstraint(SpringLayout.NORTH, lblNewName, 18, SpringLayout.SOUTH, lblName_1);
		springLayout.putConstraint(SpringLayout.WEST, lblNewName, 0, SpringLayout.WEST, lblCategory);
		add(lblNewName);
		
		JLabel lblCategory_1 = new JLabel("Category");
		springLayout.putConstraint(SpringLayout.NORTH, lblCategory_1, 17, SpringLayout.SOUTH, lblNewName);
		springLayout.putConstraint(SpringLayout.EAST, lblCategory_1, 0, SpringLayout.EAST, lblName);
		add(lblCategory_1);
		
		JLabel lblSpecification_1 = new JLabel("Specification");
		springLayout.putConstraint(SpringLayout.NORTH, lblSpecification_1, 16, SpringLayout.SOUTH, lblCategory_1);
		springLayout.putConstraint(SpringLayout.EAST, lblSpecification_1, 0, SpringLayout.EAST, lblName);
		add(lblSpecification_1);
		
		JLabel lblUnit_1 = new JLabel("Unit");
		springLayout.putConstraint(SpringLayout.NORTH, lblUnit_1, 18, SpringLayout.SOUTH, lblSpecification_1);
		springLayout.putConstraint(SpringLayout.EAST, lblUnit_1, 0, SpringLayout.EAST, lblName);
		add(lblUnit_1);
		
		editcbMaterialName = new JComboBox();
		springLayout.putConstraint(SpringLayout.NORTH, editcbMaterialName, 61, SpringLayout.SOUTH, btnAdd);
		springLayout.putConstraint(SpringLayout.WEST, editcbMaterialName, 6, SpringLayout.EAST, lblName_1);
		springLayout.putConstraint(SpringLayout.EAST, editcbMaterialName, 0, SpringLayout.EAST, addTfName);
		add(editcbMaterialName);
		
		editTfNewName = new JTextField();
		springLayout.putConstraint(SpringLayout.NORTH, editTfNewName, 12, SpringLayout.SOUTH, editcbMaterialName);
		springLayout.putConstraint(SpringLayout.WEST, editTfNewName, 0, SpringLayout.WEST, addTfName);
		springLayout.putConstraint(SpringLayout.EAST, editTfNewName, 0, SpringLayout.EAST, addTfName);
		editTfNewName.setColumns(10);
		add(editTfNewName);
		
		editCbCategory = new JComboBox();
		springLayout.putConstraint(SpringLayout.NORTH, editCbCategory, 0, SpringLayout.NORTH, lblCategory_1);
		springLayout.putConstraint(SpringLayout.WEST, editCbCategory, 0, SpringLayout.WEST, addTfName);
		springLayout.putConstraint(SpringLayout.EAST, editCbCategory, 0, SpringLayout.EAST, addTfName);
		add(editCbCategory);
		
		editCbSpecification = new JComboBox();
		springLayout.putConstraint(SpringLayout.NORTH, editCbSpecification, 0, SpringLayout.NORTH, lblSpecification_1);
		springLayout.putConstraint(SpringLayout.WEST, editCbSpecification, 0, SpringLayout.WEST, addTfName);
		springLayout.putConstraint(SpringLayout.EAST, editCbSpecification, 0, SpringLayout.EAST, addTfName);
		add(editCbSpecification);
		
		editTfUnit = new JTextField();
		springLayout.putConstraint(SpringLayout.NORTH, editTfUnit, 0, SpringLayout.NORTH, lblUnit_1);
		springLayout.putConstraint(SpringLayout.WEST, editTfUnit, 0, SpringLayout.WEST, addTfName);
		springLayout.putConstraint(SpringLayout.EAST, editTfUnit, 0, SpringLayout.EAST, addTfName);
		editTfUnit.setColumns(10);
		add(editTfUnit);
		
		btnUpdate = new JButton("Update");
		springLayout.putConstraint(SpringLayout.WEST, btnUpdate, 0, SpringLayout.WEST, btnAdd);
		springLayout.putConstraint(SpringLayout.SOUTH, btnUpdate, -10, SpringLayout.SOUTH, this);
		add(btnUpdate);
		btnAdd.setActionCommand("update");
		
		rdbtnActive = new JRadioButton("Active");
		buttonGroup.add(rdbtnActive);
		springLayout.putConstraint(SpringLayout.NORTH, rdbtnActive, 6, SpringLayout.SOUTH, editTfUnit);
		springLayout.putConstraint(SpringLayout.WEST, rdbtnActive, 0, SpringLayout.WEST, addTfName);
		add(rdbtnActive);
		
		rdbtnInactive = new JRadioButton("Inactive");
		buttonGroup.add(rdbtnInactive);
		springLayout.putConstraint(SpringLayout.NORTH, rdbtnInactive, 6, SpringLayout.SOUTH, editTfUnit);
		springLayout.putConstraint(SpringLayout.WEST, rdbtnInactive, 21, SpringLayout.EAST, rdbtnActive);
		add(rdbtnInactive);
	}
	
	public JTextField getAddTfName() {
		return addTfName;
	}
	public void setAddTfName(JTextField addTfName) {
		this.addTfName = addTfName;
	}
	public JTextField getAddTfSpecification() {
		return addTfSpecification;
	}
	public void setAddTfSpecification(JTextField addTfSpecification) {
		this.addTfSpecification = addTfSpecification;
	}
	public JTextField getAddTfUnit() {
		return addTfUnit;
	}
	public void setAddTfUnit(JTextField addTfUnit) {
		this.addTfUnit = addTfUnit;
	}
	
	public JTextField getEditTfNewName() {
		return editTfNewName;
	}
	public void setEditTfNewName(JTextField editTfNewName) {
		this.editTfNewName = editTfNewName;
	}
	
	public JComboBox getEditCbSpecification() {
		return editCbSpecification;
	}

	public void setEditCbSpecification(JComboBox editCbSpecification) {
		this.editCbSpecification = editCbSpecification;
	}

	public JTextField getEditTfUnit() {
		return editTfUnit;
	}
	public void setEditTfUnit(JTextField editTfUnit) {
		this.editTfUnit = editTfUnit;
	}
	public JComboBox getAddCbCategory() {
		return addCbCategory;
	}
	public void setAddCbCategory(JComboBox addCbCategory) {
		this.addCbCategory = addCbCategory;
	}
	public JButton getBtnAdd() {
		return btnAdd;
	}
	public void setBtnAdd(JButton btnAdd) {
		this.btnAdd = btnAdd;
	}
	public JComboBox getEditCbCategory() {
		return editCbCategory;
	}
	public void setEditCbCategory(JComboBox editCbCategory) {
		this.editCbCategory = editCbCategory;
	}
	public JButton getBtnUpdate() {
		return btnUpdate;
	}
	public void setBtnUpdate(JButton btnUpdate) {
		this.btnUpdate = btnUpdate;
	}

	public JRadioButton getRdbtnInactive() {
		return rdbtnInactive;
	}

	public void setRdbtnInactive(JRadioButton rdbtnInactive) {
		this.rdbtnInactive = rdbtnInactive;
	}

	public JRadioButton getRdbtnActive() {
		return rdbtnActive;
	}

	public void setRdbtnActive(JRadioButton rdbtnActive) {
		this.rdbtnActive = rdbtnActive;
	}

	public JComboBox getEditcbMaterialName() {
		return editcbMaterialName;
	}

	public void setEditcbMaterialName(JComboBox editcbMaterialName) {
		this.editcbMaterialName = editcbMaterialName;
	}
	
	
}
